//
//  TestVideoViewController.m
//  muce
//
//  Created by  yunshao on 2018/3/22.
//  Copyright © 2018年  yunshao. All rights reserved.
//

#import "TestVideoViewController.h"
#import "pch.h"
#import "SelVideoPlayer.h"
#import "SelPlayerConfiguration.h"
#import "SelPlaybackControls.h"
#import "Masonry.h"
#import "LPRequestParser.h"
#import "LPQuestionnaireViewController.h"
#import "TextFiledViewController.h"
#import "LPProgressHUD.h"


#define goodOrDoubtButton_Tag 3253

@interface TestVideoViewController ()<UITableViewDelegate,UITableViewDataSource,UITextFieldDelegate>{
    
}
@property(nonatomic,strong)UIView * backView;
@property(nonatomic,strong)UIButton * backButton;               //返回按钮
@property(nonatomic,strong)UILabel * titleLable;                //标题
//@property(nonatomic,strong)UIButton *goodOrDoubtButton;         //点赞和疑问
@property (nonatomic,strong)UIView * alerView;
@property (nonatomic,strong)UILabel * alertLabel;           //提示文字
@property(nonatomic,strong)UIButton *alertBtn;              //提示按钮。



@property(nonatomic,strong)NSArray * dataArray;              //吐槽，建议，疑问，点赞源数据。
@property(nonatomic,strong)NSMutableArray *childMutableArray;                 //子菜单列表数据。
@property(nonatomic,strong)NSMutableArray * childMutableArray_One;             //子菜单列表字典数据

@property(nonatomic,assign)NSInteger   fatherId;                //父ID
@property(nonatomic,strong)UITableView * childTableView;        //子菜单表格


@property(nonatomic,strong)UIView * sendView;                   //发送评论视图
@property(nonatomic,strong)UITextField * sendTextFiled;         //发送文本框
@property(nonatomic,strong)UILabel * sendLabel;                 //提示文字
@property(nonatomic,strong)UIButton * sendButton;               //发送按钮。

@property(nonatomic,strong)NSString * pointTimeString;          //评论时间
@property(nonatomic,strong)NSString * contentString;            //评论类容
@property(nonatomic,strong)NSString * menuId;                   //父ID
@property(nonatomic,strong)NSString * s_MenuId;                 //子ID

@property(nonatomic,strong)UILabel * redLabel;                  //屏幕上的小红点 （两个）
@property(nonatomic,strong)UILabel * redLabel_Two;                  //屏幕上的小红点 （两个）



@property (nonatomic, strong) SelVideoPlayer *player;
@property (nonatomic, strong) SelPlayerConfiguration *configuration;
@property (nonatomic, strong) SelPlaybackControls *selPlay;             //播放器相关的

@property (nonatomic, strong) UIButton *contentBtn;             // 当前选中按钮
@property (nonatomic,strong)NSString *playTimeString;           //播放时长


@end

@implementation TestVideoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self requData];
    [self addMainView];
}


-(void)viewWillAppear:(BOOL)animated{
    [_player _playVideo];
}

#pragma mark--init**********************************初始化*******************************
-(instancetype)init{
    self = [super init];
    if (self) {
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(isEnd) name:@"isEnd" object:nil];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(suspended:) name:@"suspended" object:nil];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(nowTime:) name:@"NowTime" object:nil];
        
        
    }
    return self;
}
#pragma mark *********************移除通知 *************************
-(void)dealloc{
    
    [[NSNotificationCenter defaultCenter]removeObserver:self name:@"isEnd" object:nil];
    [[NSNotificationCenter defaultCenter]removeObserver:self name:@"suspended" object:nil];
    [[NSNotificationCenter defaultCenter]removeObserver:self name:@"NowTime" object:nil];
}

-(void)isEnd{
  
    
   
    [ LPRequestParser postLoginAppUserName:[NSString stringWithFormat:@"%@",[LPCommonTool readphoneNumber]] securityCode:[LPCommonTool readUserDefaultObjectForKey:DSUSERKEY][@"password"] url:FinishParticipate block:^(id responseObject, NSError *error) {
        if (responseObject) {
            // [LPProgressHUD showWithStatus:@"测评完成" duration:3.0f transform:CGAffineTransformMakeRotation(M_PI)];
            //这里要根据，返回的东西，来判断是非返回上一个页面
            _alerView.hidden = NO;
           
            
        }
        
    }];
    
}
//进入做题页面。
-(void)suspended:(NSNotification *)info{
    NSLog(@"%@", info);
    
    LPQuestionnaireViewController * articleVc =[[LPQuestionnaireViewController alloc]init];
    articleVc.questionaireDic = info.userInfo;
    [_player _pauseVideo];
    [self presentViewController:articleVc animated:NO completion:nil];
    
}
-(void)nowTime:(NSNotification *)info{
    NSLog(@"%@",info.userInfo);
    self.pointTimeString = [NSString stringWithFormat:@"%@",info.userInfo[@"NowTime"][@"nowtime"]];
    self.playTimeString =[NSString stringWithFormat:@"%@",info.userInfo[@"NowTime"][@"nowtime"]];
}

-(void)requData{
    
    [LPRequestParser postLoginAppUserName:[NSString stringWithFormat:@"%@",[LPCommonTool readphoneNumber]] securityCode:[LPCommonTool readUserDefaultObjectForKey:DSUSERKEY][@"password"] url:OwnpaperApp block:^(id responseObject, NSError *error) {
        if ([responseObject count] > 0) {
            //没有状态返回，只有用数据的个数来处理了。
            self.dataArray = responseObject;
        }
        
    }];
    
    
    
    
}

-(void)backButtonClicked{
    
    
    NSMutableDictionary * histerDic = [[NSMutableDictionary alloc]init];
    [histerDic setValue:self.playTimeString forKey:@"historyTime"];
    [LPCommonTool writeHisteryTimeObject:histerDic forKey:DSHISTERY];
    
    [self dismissViewControllerAnimated:YES completion:nil];

   
    
    
}

-(void)addMainView{
    
    
    
    
    
 
    
    
    _backView = [[UIView alloc]initWithFrame:CGRectMake(DSDevice_W - DSFixedPX(110), 0, DSFixedPX(110), DSDevice_H)];
    _backView.backgroundColor = DSColorWithHex(0x3279ca);
    _backView.userInteractionEnabled = YES;
    [self.view addSubview:_backView];
    
    
    
    
    _backButton = [UIButton buttonWithType:UIButtonTypeCustom];
    _backButton.frame = CGRectMake(DSFixedPX(30), DSFixedPX(10), DSFixedPX(50), DSFixedPX(50));
   // _backButton.center =CGPointMake(DSDevice_W - DSFixedPX(110)/2.0f, DSFixedPX(110)/2.0f);
    _backButton.imageEdgeInsets = UIEdgeInsetsMake(5, 5, 5, 5);

    [_backButton setImage:[UIImage imageNamed:@"title_back"] forState:UIControlStateNormal];
      _backButton.transform = CGAffineTransformMakeRotation(M_PI/2);
    [_backButton addTarget:self action:@selector(backButtonClicked) forControlEvents:UIControlEventTouchUpInside];
    [_backView addSubview:_backButton];
    
    
    _titleLable = [[UILabel alloc]initWithFrame:CGRectMake(DSFixedPX(40), DSFixedPX(40), DSDevice_H - DSFixedPX(80), DSFixedPX(50))];
    _titleLable.text = self.titleString;
    [_titleLable sizeToFit];
    _titleLable.center = CGPointMake( DSFixedPX(110)/2.0f, DSDevice_H /2);
    _titleLable.transform = CGAffineTransformMakeRotation(M_PI/2);
    
    _titleLable.font = DSFontSize(16);
    _titleLable.textAlignment = NSTextAlignmentCenter;
    _titleLable.textColor = DSColorWithHex(0xffffff);
    [_backView addSubview:_titleLable];

    
    
    //0 疑问   1 点赞   2建议  3 吐槽
    for (int i = 0; i <4; i++) {
        UIButton *goodOrDoubtButton = [UIButton buttonWithType:UIButtonTypeCustom];
        if (i == 0) {
            goodOrDoubtButton.frame = CGRectMake(0,DSFixedPX(0),( DSDevice_W - DSFixedPX(110) )/2.0f ,DSFixedPX(110));
            [goodOrDoubtButton setImage:[UIImage imageNamed:@"55"] forState:UIControlStateNormal];
            [goodOrDoubtButton setImage:[UIImage imageNamed:@"77"] forState:UIControlStateSelected];
              goodOrDoubtButton.tag = goodOrDoubtButton_Tag + 1;
        }else if (i == 1){
            goodOrDoubtButton.frame = CGRectMake((DSDevice_W - DSFixedPX(110) )/2.0f,0,( DSDevice_W - DSFixedPX(110) )/2.0f,DSFixedPX(110));
            [goodOrDoubtButton setImage:[UIImage imageNamed:@"11"] forState:UIControlStateNormal];
            [goodOrDoubtButton setImage:[UIImage imageNamed:@"00"] forState:UIControlStateSelected];
              goodOrDoubtButton.tag = goodOrDoubtButton_Tag + 0;
        }else if (i == 2){
            
            goodOrDoubtButton.frame = CGRectMake(0, DSDevice_H - DSFixedPX(110),( DSDevice_W - DSFixedPX(110) )/2.0f,DSFixedPX(110));
            [goodOrDoubtButton setImage:[UIImage imageNamed:@"22"] forState:UIControlStateNormal];
            [goodOrDoubtButton setImage:[UIImage imageNamed:@"33"] forState:UIControlStateSelected];
            goodOrDoubtButton.tag = goodOrDoubtButton_Tag + 3;
            
        }else if (i == 3){
            goodOrDoubtButton.frame = CGRectMake((DSDevice_W - DSFixedPX(110) )/2.0f,DSDevice_H - DSFixedPX(110),( DSDevice_W - DSFixedPX(110) )/2.0f,DSFixedPX(110));
            [goodOrDoubtButton setImage:[UIImage imageNamed:@"44"] forState:UIControlStateNormal];
            [goodOrDoubtButton setImage:[UIImage imageNamed:@"66"] forState:UIControlStateSelected];
            goodOrDoubtButton.tag = goodOrDoubtButton_Tag + 2;
            
        }
         //  _goodOrDoubtButton.transform = CGAffineTransformMakeRotation(M_PI/2);
      //  goodOrDoubtButton.tag = goodOrDoubtButton_Tag + i;
        goodOrDoubtButton.contentMode = UIViewContentModeScaleToFill;
        [goodOrDoubtButton addTarget:self action:@selector(goodOrDoubtButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
        // self.selectButtonOne = _goodOrDoubtButton;
//        _goodOrDoubtButton.backgroundColor = [UIColor redColor];
        
        [self.view addSubview:goodOrDoubtButton];
        
    }
    
    _configuration = [[SelPlayerConfiguration alloc]init];
    _configuration.shouldAutoPlay = YES;             //自动播放
    _configuration.supportedDoubleTap = YES;         //双击播放暂停
    _configuration.shouldAutorotate = NO;           //自动旋转
    _configuration.repeatPlay = NO;                 //重复播放
    _configuration.statusBarHideState = SelStatusBarHideStateFollowControls;     //状态栏的隐藏显示
       // _configuration.sourceUrl = [NSURL URLWithString:@"http://120.25.226.186:32812/resources/videos/minion_02.mp4"];                  //视频源
    _configuration.sourceUrl = [NSURL URLWithString:self.addressUrl];
    _configuration.videoGravity = SelVideoGravityResizeAspect;           //拉伸方式
    _player = [[SelVideoPlayer alloc]initWithFrame:CGRectMake(DSFixedPX(0), DSFixedPX(0), DSDevice_H - DSFixedPX(110) - DSFixedPX(110), DSDevice_W - DSFixedPX(110)) configuration:_configuration];
    _player.center = CGPointMake((DSDevice_W - DSFixedPX(110))/2.0f, DSDevice_H/2.0);
    _player.transform = CGAffineTransformMakeRotation(M_PI/2);
 
    
    
    
    [self.view addSubview:_player];
    
    
    
    
    NSInteger  heightAverage  = self.player.frame.size.width / 11.0f;   //每一份的高度
    NSInteger  widthAverage   =self.player.frame.size.height / 19.0f;   //每一份的宽度
    
    NSLog(@"每一分：%ld,%ld",heightAverage,widthAverage);
    
    
    NSInteger heigth_One ;           //第一个点
    NSInteger width_One;
    
    NSInteger  height_Two;          //第二个点
    NSInteger  width_Two;
    
    if (self.x_One  == 0 ) {
        width_One = self.player.frame.size.height / 2.0f;
    }else{
        width_One = self.player.frame.size.height / 2.0f + widthAverage * self.x_One;
    }
    
    if (self.y_One  == 0 ) {
        heigth_One = self.player.frame.size.width / 2.0f;
    }else {
        heigth_One = self.player.frame.size.width / 2.0f  - heightAverage * self.y_One;
    }
    
    // 第二个点
    if (self.x_Two  == 0 ) {
        width_Two = self.player.frame.size.height / 2.0f;
    }else{
        width_Two = self.player.frame.size.height / 2.0f  + widthAverage * self.x_Two;
    }
    
    if (self.y_Two  == 0 ) {
        height_Two = self.player.frame.size.width / 2.0f;
    }else {
        height_Two = self.player.frame.size.width / 2.0f  - heightAverage * self.y_Two;
    }
    
    
    NSLog(@"%ld,%ld,%ld,%ld",self.x_One,self.y_One,self.x_Two,self.y_Two);
    NSLog(@"位置：%ld,%ld,%ld,%ld",heigth_One,width_One,height_Two,width_Two);
    
    
    self.redLabel = [[UILabel alloc]init];
    self.redLabel = [[UILabel alloc]initWithFrame:CGRectMake( width_One,heigth_One, DSFixedPX(10), DSFixedPX(10))];
    self.redLabel.backgroundColor = [UIColor redColor];
    self.redLabel.layer.masksToBounds = YES;
    self.redLabel.layer.cornerRadius = DSFixedPX(10)/2.0f;
    self.redLabel.transform = CGAffineTransformMakeRotation(-M_PI/2);
    [_player addSubview:self.redLabel];
    
    self.redLabel_Two = [[UILabel alloc]init];
    self.redLabel_Two.frame = CGRectMake( width_Two, height_Two, DSFixedPX(10), DSFixedPX(10));
    
    self.redLabel_Two.backgroundColor = [UIColor whiteColor];
    self.redLabel_Two.layer.masksToBounds = YES;
    
    self.redLabel_Two.layer.cornerRadius = DSFixedPX(10)/2.0f;
    self.redLabel_Two.transform = CGAffineTransformMakeRotation(-M_PI/2);
    [_player addSubview:self.redLabel_Two];

    
    _alerView = [[UIView alloc]initWithFrame:CGRectMake(0,0, DSFixedPX(400), DSFixedPX(300))];
    _alerView.center = CGPointMake(DSDevice_W/2, DSDevice_H/2);
    _alerView.transform = CGAffineTransformMakeRotation(M_PI/2);
    _alerView.layer.masksToBounds = YES;
    _alerView.hidden = YES;
    _alerView.layer.cornerRadius = 10.0;
    _alerView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:_alerView];
    
    _alertLabel = [[UILabel alloc]initWithFrame:CGRectMake(DSFixedPX(40), DSFixedPX(100), DSFixedPX(320), DSFixedPX(50))];
    _alertLabel.text = @"测评完成!";
    _alertLabel.textColor = [UIColor grayColor];
    _alertLabel.textAlignment = NSTextAlignmentCenter;
    [_alerView addSubview:_alertLabel];
    
    _alertBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    _alertBtn.frame = CGRectMake(DSFixedPX(40), DSFixedPX(220), DSFixedPX(320), DSFixedPX(40));
    [_alertBtn setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
    [_alertBtn setTitle:@"确定" forState:UIControlStateNormal];
    [_alertBtn addTarget:self action:@selector(alertBtnClicked) forControlEvents:UIControlEventTouchUpInside];
    [_alerView addSubview:_alertBtn];
    
    
    
    
    //_sendView = [[UIView alloc]initWithFrame:CGRectMake(DSFixedPX(100), DSFixedPX(110) + DSFixedPX(50), DSDevice_H - DSFixedPX(110) * 2,DSFixedPX(110))];
//     _sendView.transform =CGAffineTransformMakeRotation(M_PI/2);
//    _sendView.center = CGPointMake(CGRectGetWidth(_sendView.frame), DSFixedPX(110) + CGRectGetHeight(_sendView.frame)/2.0f);
//    _sendView.backgroundColor = [UIColor clearColor];
//    _sendView.hidden = YES;

//    _sendTextFiled = [[UITextField alloc]initWithFrame:CGRectMake(0, DSFixedPX(10), DSDevice_H - DSFixedPX(110) - DSFixedPX(110) - DSFixedPX(130), DSFixedPX(80))];
//
//    _sendTextFiled.backgroundColor = DSColorWithHex(0x367bc8);
//    _sendTextFiled.alpha = 0.75f;
//    _sendTextFiled.layer.masksToBounds = YES;
//    _sendTextFiled.layer.cornerRadius = DSFixedPX(5);
//    _sendTextFiled.textColor = [UIColor whiteColor];
//    _sendTextFiled.delegate = self;
//    // [_sendTextFiled addTarget:self action:@selector(sendTextFiledClicked) forControlEvents:UIControlEventTouchUpInside];
//    //_sendTextFiled.placeholder = @" 请输入宝贵意见";
//    [_sendView addSubview:_sendTextFiled];
//
//    _sendLabel = [[UILabel alloc]initWithFrame:CGRectMake(DSFixedPX(10), DSFixedPX(10), DSDevice_H - DSFixedPX(260), DSFixedPX(80))];
//    _sendLabel.text = @"请输入宝贵意见";
//    _sendLabel.textColor = [UIColor whiteColor];
//    [_sendView addSubview:_sendLabel];
//
//    _sendButton = [UIButton buttonWithType:UIButtonTypeCustom];
//    _sendButton.frame = CGRectMake(CGRectGetMaxX(_sendTextFiled.frame) + DSFixedPX(5), DSFixedPX(10), DSFixedPX(100), DSFixedPX(80));
//    _sendButton.layer.masksToBounds = YES;
//    _sendButton.layer.cornerRadius = DSFixedPX(5);
//    _sendButton.backgroundColor = DSColorWithHex(0x20ac19);
//    [_sendButton setTitle:@"发送" forState:UIControlStateNormal];
//    [_sendButton addTarget:self action:@selector(sendButtonClicked) forControlEvents:UIControlEventTouchUpInside];
//    [_sendView addSubview:_sendButton];
//
//
//    [self.view addSubview:_sendView];
    
    
    

}



//-(void)sendButtonClicked{
//    self.contentString = _sendTextFiled.text;
//    [self sendHttp];
//
//}
//
//-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
//    _sendLabel.hidden = YES;
//
//
//
//    return YES;
//
//}
//-(void)textFieldDidEndEditing:(UITextField *)textField{
//    if (_sendTextFiled.text.length <= 0) {
//        _sendLabel.hidden = NO;
//    }
//}


-(void)alertBtnClicked{
    [self backButtonClicked];
    //视频播放完以后，历史记录就清零
    NSMutableDictionary * histerDic = [[NSMutableDictionary alloc]init];
    [histerDic setValue:@(0) forKey:@"historyTime"];
    [LPCommonTool writeHisteryTimeObject:histerDic forKey:DSHISTERY];
}


-(void)goodOrDoubtButtonClicked:(UIButton *)sender{
    //点击按钮后 ，表格显示
    if (self.childTableView) {
        [self.childTableView removeFromSuperview];
        self.childTableView = nil;
    }
    
    sender.selected = !sender.selected;
    if (!sender.isSelected) {
        return;
    }else {
        if (sender != _contentBtn) {
            _contentBtn.selected = NO;
          
        }
        _contentBtn = sender;
    }
    
    if (sender.selected == YES) {
         [_player _pauseVideo];
    }else{
         [_player _playVideo];
    }
    
    
    
    self.childMutableArray = [[NSMutableArray alloc]init];
    self.childMutableArray_One = [[NSMutableArray alloc]init];
    
    
    
    
    NSInteger selectIndex = sender.tag - goodOrDoubtButton_Tag;
    // 对应按钮id
    self.fatherId = [self.dataArray[selectIndex][@"id"] integerValue];
    
        [LPRequestParser postOwnpaperAttachedFatherId:self.fatherId url:OwnpaperAttachedApp UserName:[NSString stringWithFormat:@"%@",[LPCommonTool readphoneNumber]] securityCode:[LPCommonTool readUserDefaultObjectForKey:DSUSERKEY][@"password"] block:^(id responseObject, NSError *error) {
            if ([responseObject count] >0) {
                for (int i = 0; i<[responseObject count]; i++) {
                    [self.childMutableArray addObject:responseObject[i][@"menu_name"]];
                    [self.childMutableArray_One addObject:responseObject[i]];
                }
                
                [self.childMutableArray addObject:@"自定义"];
                [self.childMutableArray_One addObject:responseObject[0][@"menu_id"]];
                
                if(self.fatherId == 91 || self.fatherId == 93){
                  
                }
            }
            
            //重新初始化，然后定义tableview的位置。
            self.childTableView  = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStylePlain];
            self.childTableView.delegate = self;
            self.childTableView.dataSource = self;
            self.childTableView.tableFooterView = [UIView new];
            [self.view addSubview:self.childTableView];
            CGRect rect = self.childTableView.frame;
            rect.size.width =DSFixedPX(200);
            rect.size.height = DSFixedPX(72) * self.childMutableArray.count;
            self.childTableView.frame = rect;
            [self.childTableView reloadData];
            NSLog(@"数组：%@",self.childMutableArray);
            
            self.childTableView.transform =CGAffineTransformMakeRotation(M_PI/2  );
            if (selectIndex == 0 || selectIndex == 1) {
                CGRect rect = self.childTableView.frame;
                rect.origin = CGPointMake(DSDevice_W - DSFixedPX(110) - DSFixedPX(72) * self.childMutableArray.count, DSFixedPX(110));
                self.childTableView.frame = rect;
            }else{
                CGRect rect = self.childTableView.frame;
                rect.origin = CGPointMake(DSDevice_W - DSFixedPX(110) - DSFixedPX(72) * self.childMutableArray.count,DSDevice_H -  DSFixedPX(200) - DSFixedPX(110));
                self.childTableView.frame = rect;
            }
        }];
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.childMutableArray.count;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return  DSFixedPX(72);
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"testCell"];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"testCell"];
    }
    cell.textLabel.text = [NSString stringWithFormat:@"%@",self.childMutableArray[indexPath.row]];
    cell.textLabel.font = DSFontSize(13);
    cell.textLabel.textAlignment = NSTextAlignmentCenter;
    cell.textLabel.textColor = DSColorWithHex(0xffffff);
    cell.backgroundColor = DSColorWithHex(0x333333);
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    NSLog(@"%@",self.childMutableArray_One[indexPath.row]);
    //点击cell的时候，接收通知
    //点击了cell以后，表格隐藏。
    
     [_player _playVideo];
    
    self.childTableView.hidden = YES;
    
   
    
    //如果是最后一行，
    if(self.fatherId == 91 || self.fatherId == 93){
        if (indexPath.row == [self.childMutableArray_One count] - 1 ) {
            //如果点击的是其他按钮，那么就需要先暂停播放视频。
            [_player _pauseVideo];
            
            _sendView.hidden = NO;
            self.menuId = [NSString stringWithFormat:@"%@",self.childMutableArray_One[indexPath.row]];
            self.s_MenuId = @"0";
            
            TextFiledViewController * textFiedVc= [[TextFiledViewController alloc]init];
            textFiedVc.menuId = self.menuId;
            textFiedVc.s_MenuId = self.s_MenuId;
            textFiedVc.pointTimeString = self.pointTimeString;
            [self presentViewController:textFiedVc animated:YES completion:nil];
        }else{
            //不是最后一行
            self.menuId = [NSString stringWithFormat:@"%@",self.childMutableArray_One[indexPath.row][@"menu_id"]];      //id
            self.s_MenuId =[NSString stringWithFormat:@"%@",self.childMutableArray_One[indexPath.row][@"id"]];          //子ID
            self.contentString =[NSString stringWithFormat:@"%@",self.childMutableArray_One[indexPath.row][@"menu_name"]];  //内容
            _sendView.hidden = YES;
            [self sendHttp];
        }
    }else{
        //不是最后一行
        self.menuId = [NSString stringWithFormat:@"%@",self.childMutableArray_One[indexPath.row][@"menu_id"]];      //id
        self.s_MenuId =[NSString stringWithFormat:@"%@",self.childMutableArray_One[indexPath.row][@"id"]];          //子ID
        self.contentString =[NSString stringWithFormat:@"%@",self.childMutableArray_One[indexPath.row][@"menu_name"]];  //内容
        _sendView.hidden = YES;
        [self sendHttp];
    }
}
-(void)sendHttp{
    //预览用户
    if ([[LPCommonTool readIdengit] integerValue] == 1) {
        [LPProgressHUD showWithStatus:@"评论成功" duration:3.0f transform:CGAffineTransformMakeRotation(M_PI)];
        return;
    }
    // 官方用户。
    NSDictionary *dic = [LPCommonTool readUserDefaultObjectForKey:DSUSERKEY];
    [LPRequestParser postSaveOwnpaperAppUname:[NSString stringWithFormat:@"%@",[LPCommonTool readphoneNumber]] url:SaveOwnpaperApp SecurityCode:dic[@"password"] Point_time:self.pointTimeString MenuId:self.menuId S_menu_id:self.s_MenuId Menu_content:self.contentString block:^(id responseObject, NSError *error) {
        if (responseObject) {
            if ([responseObject[@"status"] isEqualToString:@"success"]) {
                [LPProgressHUD showWithStatus:@"评论成功" duration:3.0f transform:CGAffineTransformMakeRotation(M_PI)];
                
            }else{
                [LPProgressHUD showWithStatus:@"评论失败" duration:3.0f transform:CGAffineTransformMakeRotation(M_PI)];
            }
        }else{

            [LPProgressHUD showWithStatus:@"评论失败" duration:3.0f transform:CGAffineTransformMakeRotation(M_PI)];
        }
    }];
}

//隐藏状态栏
- (BOOL)prefersStatusBarHidden {
    return YES;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
